package com.fiveflavors.suittar.gui;

import java.awt.Font;

import javax.swing.JTabbedPane;

import twitter4j.UserWithStatus;

import com.fiveflavors.suittar.gui.mainpanel.SuittarMainPane;

public class SuittarTabbedPane extends JTabbedPane {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8454128995845913252L;
	public static final int TAB_OWNER_FRIENDS = 0;
	public static final int TAB_OWNER_PROFILE = 1;
	public static final int TAB_OWNER_REPLIES = 2;
	public static final int TAB_OWNER_FOLLOWING = 3;
	public static final int TAB_OWNER_FOLLOWERS = 4;
	public static final int TAB_OWNER_DIRECT_MESSAGES = 5;

	public static final int TAB_OTHER_FRIENDS = 0;
	public static final int TAB_OTHER_PROFILE = 1;
	public static final int TAB_OTHER_FOLLOWING = 2;

	private boolean owner = false;
	
	private UserWithStatus user;
	
	private SuittarMainPane[] mainPane = null;
	
	public SuittarTabbedPane() {
		this(true);		
	}
	
	public SuittarTabbedPane(UserWithStatus user) {
		this(false);
		this.user = user;
	}
	                         
	private SuittarTabbedPane(boolean owner) {
		
		super(JTabbedPane.BOTTOM,JTabbedPane.SCROLL_TAB_LAYOUT);
		
        Font font = new Font(getFont().getFontName(),getFont().getStyle(),11);
        setFont(font);

		this.owner = owner;
		
		int tabCount = (owner) ? 6 : 3;
		mainPane = new SuittarMainPane[tabCount];
		for (int i = 0; i < tabCount; i++) {
			mainPane[i] = new SuittarMainPane();
		}
		
		if (owner) {
	        addTab("Friends", mainPane[TAB_OWNER_FRIENDS]);
	        addTab("Profile", mainPane[TAB_OWNER_PROFILE]);
	        addTab("Replies", mainPane[TAB_OWNER_REPLIES]);
	        addTab("Following", mainPane[TAB_OWNER_FOLLOWING]);
	        addTab("Followers", mainPane[TAB_OWNER_FOLLOWERS]);
	        addTab("DirectMessages", mainPane[TAB_OWNER_DIRECT_MESSAGES]);
		}
		else {
	        addTab("Friends", mainPane[TAB_OTHER_FRIENDS]);
	        addTab("Profile", mainPane[TAB_OTHER_PROFILE]);
	        addTab("Following", mainPane[TAB_OTHER_FOLLOWING]);
		}
		
	}

	public boolean isOwner() {
		return owner;
	}

	public void setOwner(boolean owner) {
		this.owner = owner;
	}

	public SuittarMainPane getSelectedPane() {
		return mainPane[getSelectedIndex()];
	}
	
	public SuittarMainPane getPane(int index) {
		return mainPane[index];
	}
	
	public SuittarMainPane[] getPaneAll() {
		return mainPane;
	}
	
	public UserWithStatus getUser() {
		return user;
	}
}
